import { createReducer, on ,createSelector} from '@ngrx/store';
import { increment, decrement, reset } from '../actions/counter.actions';

export interface counterState {
  count: number;
}
export const initialState: counterState = {count: 0};

export const counterReducers = createReducer(
  initialState,
  on(increment, (state, {num}) => {
    return {...state , count: state.count + num}
  }),
  on(decrement, (state, {num}) => ({...state , count: state.count - num})),
  on(reset, (state) => ({...state , count: 0}))
);
